

package com.hazelcast.internal.serialization;

import com.hazelcast.nio.serialization.DataSerializableFactory;

import java.util.Map;

public interface DataSerializerHook {

    int F_ID_OFFSET_WEBMODULE = -1000;
    int F_ID_OFFSET_HIBERNATE = -2000;

    int getFactoryId();

    DataSerializableFactory createFactory();

    /**
     * Gives the hook a chance to further configure factories after all
     * factories were created. It can be used for configuring constructors for
     * classes in submodules, for which the factoryId and classId cannot be
     * changed.
     */
    default void afterFactoriesCreated(Map<Integer, DataSerializableFactory> factories) {
        // nothing by default
    }

    /**
     * Gives the hook a chance to decide for itself if it should get registered or not.
     */
    default boolean shouldRegister() {
        return true;
    }
}
